#!/bin/bash

awk 'BEGIN{
	FS =",";
	OFS=",";
	start=1297980408;
	i=1;
	count[""]=0;
	
}{
	time=$1-start;
	if(time<=180*i && time>=180*(i-1))
	{
		count[i]++;
		cpu1[i]+=$2;
		cpu2[i]+=$3;
	}
	else{
		i++;
		count[i]++;
		cpu1[i]+=$2;
		cpu2[i]+=$3;
	}
	
}END{
		for(k in count)
		{
			if(count[k]!=0)
			{
				print (k-1)*3,cpu1[k]/count[k],cpu2[k]/count[k],cpu1[k]/count[k]+cpu2[k]/count[k];
			}
		}	
}' $1 |sort -t "," -n -k1,1n >>3perf
	
